# Compiler settings
CC = gcc
CFLAGS = -Wall -Wextra -O2 -g
LDFLAGS = -lmodbus -lpthread

# Project settings
TARGET = modbus_control
SRC = modbus112.c shmem.c msg_queue_peer.c
OBJ = $(SRC:.c=.o)
HEADERS = shmem.h msg_queue_peer.h

# Default target - build the executable
all: $(TARGET)

# Link object files to create executable
$(TARGET): $(OBJ)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

# Compile source files to object files
%.o: %.c $(HEADERS)
	$(CC) $(CFLAGS) -c $< -o $@

# Clean build artifacts
clean:
	rm -f $(TARGET) $(OBJ)